#include <stdio.h>
#include <stdlib.h>


#define time_after(a,b) \
	(typecheck(unsigned long, a) && \
	 typecheck(unsigned long, b) && \
	 ((long)(b) - (long)(a) < 0))
#define time_before(a,b) time_after(b,a)

#define time_after_eq(a,b) \
	(typecheck(unsigned long, a) && \
	 typecheck(unsigned long, b) && \
	 ((long)(a) - (long)(b) >= 0))
#define time_before_eq(a,b) time_after_eq(b,a)

/*
 * * Have the 32 bit jiffies value wrap 5 minutes after boot
 * * so jiffies wrap bugs show up earlier.
 * */


/*
 * * Check at compile time that something is of a particular type.
 * * Always evaluates to 1 so you may use it easily in comparisons.
 * */
#define typecheck(type,x) \
	({ type __dummy; \
	 typeof(x) __dummy2; \
	 (void)(&__dummy == &__dummy2); \
	 1; \
	 })
/*
 * * Check at compile time that 'function' is a certain type, or is a pointer
 * * to that type (needs to use typedef for the function type.)
 * */
#define typecheck_fn(type,function) \
	({ typeof(type) __tmp = function; \
	 (void)__tmp; \
	 })


typedef int (*fun)(int *,unsigned long *);
int main(void)
{

	unsigned long i=10;
	int val =0;

	val = typecheck(unsigned long,i); //if not same tpye, gcc will warn comparison of distinct pointer types lacks a cast
	printf("val=%d\n",val);

	return 0;
}

